package com.ztgf.commodity.api.client;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.ztgf.commodity.models.dto.CommodityAdvisoryPriceFileDTO;
import com.ztgf.commodity.models.service.ICommodityAdvisoryPriceFileService;
import com.ztgf.common.constant.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 * @author: chenyu.wang
 * @date: 2020-08-11
 * @description:询价模板表控制器
 */
@RestController
@RequestMapping("/api/commodityAdvisoryPriceFileApiController")
@Api(value = "CommodityAdvisoryPriceFileApiController", tags = "询价模板表API接口")
public class CommodityAdvisoryPriceFileApiController {

    @DubboReference
    private ICommodityAdvisoryPriceFileService commodityAdvisoryPriceFileService;

    @PostMapping(value = "/selectFile")
    @ApiOperation(value = "查询询价模板文件", notes = "查询询价模板文件")
    public Result selectFile() {
        Wrapper<CommodityAdvisoryPriceFileDTO> wrapper = new EntityWrapper<>();
        return new Result<>(commodityAdvisoryPriceFileService.selectOne(wrapper));
    }

    @PostMapping(value = "/selectFileByType")
    @ApiOperation(value = "根据类型查询模板文件", notes = "根据类型查询模板文件")
    public Result selectFileByType(Integer type) {
        Wrapper<CommodityAdvisoryPriceFileDTO> wrapper = new EntityWrapper<>();
        wrapper.eq("type", type);
        return new Result<>(commodityAdvisoryPriceFileService.selectOne(wrapper));
    }
}
